Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@stoplight/json
Advanced tools
Useful functions when working with JSON.
Supported in modern browsers and node.
# latest stable
yarn add @stoplight/json
JSON.parse(val)
but also returns parsing errors as well as full ast with line information.['paths', '/user', 'get']
-> #/paths/~1/user/get
.#/paths/~1/user/get
-> ['paths', '/user', 'get']
.JSON.parse(val)
but does not throw on invalid JSON.JSON.stringify(val)
but handles circular references.x.startsWith(y)
but works with strings AND arrays.lodash.startsWith(x, y)
but works with strings AND arrays.parseWithPointers
Note: Unlike most of the other functions, parseWithPointers is not exported from root. You must import by name.
import { parseWithPointers } from "@stoplight/json/parseWithPointers";
const result = parseWithPointers('{"foo": "bar"}');
console.log(result.data); // => the {foo: "bar"} JS object
console.log(result.pointers); // => the source map with a single "#/foo" pointer that has position info for the foo property
// basic example of getJsonPathForPosition and getLocationForJsonPath
import { getJsonPathForPosition, getLocationForJsonPath, parseWithPointers } from "@stoplight/json";
const result = parseWithPointers(`{
"hello": "world",
"address": {
"street": 123
}
}`);
const path = getJsonPathForPosition(result, { line: 3, character: 15 }); // line and character are 0-based
console.log(path); // -> ["address", "street"];
const position = getLocationForJsonPath(result, ["address"]);
console.log(position.range.start); // { line: 2, character: 13 } line and character are 0-based
console.log(position.range.end); // { line: 4, character: 3 } line and character are 0-based
feature/{name}
, chore/{name}
, or fix/{name}
branch.yarn
.yarn test.prod
.yarn commit
. NOTE: Commits that don't follow the conventional format will be rejected. yarn commit
creates this format for you, or you can put it together manually and then do a regular git commit
.git push
.next
branch.FAQs
Useful functions when working with JSON.
The npm package @stoplight/json receives a total of 747,827 weekly downloads. As such, @stoplight/json popularity was classified as popular.
We found that @stoplight/json demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.